package com.teamin.web.socket;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by qfu on 2017/10/27.
 */
public class SubscribeManager {


   private static Map<String,Map<String,String>> sessionMap = new HashMap<>() ;

    public static String getSubId(String userId,String subscribe) {
        Map<String, String> map = sessionMap.get(userId);
        if(map != null) {
            return map.get(subscribe) ;
        }
        return null ;
    }

    public static void deleteSub(String userId,String subscribe) {

        Map<String, String> map = sessionMap.get(userId);
        if(map != null) {
            map.remove(subscribe) ;
        }
    }

    public static void addSub(String userId,String subscribe,String subId) {

        Map<String, String> map = sessionMap.get(userId);
        if(map == null) {
            map = new HashMap<>() ;
        }
        sessionMap.put(userId,map) ;
        map.put(subscribe,subId) ;
    }
}
